package com.dkm.nettysocketdemo.myWebsite.action;

import com.dkm.nettysocketdemo.myWebsite.domain.HelmetLog;
import com.dkm.nettysocketdemo.myWebsite.service.HelmetLogService;
import com.dkm.nettysocketdemo.untils.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName : HelmetLogAction  //类名
 * @Description : 安全帽日志Action  //描述
 * @Author : 易嵘  //作者
 * @Date: 2021-03-19 11:25  //时间
 */
@RestController
@RequestMapping("HelmetLogAction")
public class HelmetLogAction {

    /**
     * 日志service
     */
    @Autowired
    HelmetLogService logService;

    /**
     *
     * @param helmetId
     * @return
     */
    @GetMapping("findHelmetId/{helmetId}")
    public Message findHelmetId(@PathVariable(value = "helmetId") String helmetId){
        Message message = new Message();
        message.setData(logService.findHelmetId(helmetId));
        message.setCode(200);
        message.setMsg("查询成功");
        return message;
    }

    /**
     * 日志新增
     * @param log 日志模型
     * @return 回调函数
     */
    @PostMapping("add")
    public Message add(HelmetLog log){
        Message message = new Message();
        message.setData(logService.add(log));
        return message;
    }
}
